using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using DTO;
namespace BUS
{
    public class tbCTDealBUS
    {
        public static void Insert(tbCTDeal ctdeal)
        {
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            ctdealDAL.Insert(ctdeal);
        }
        public static void Update(tbCTDeal ctdeal)
        {
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            ctdealDAL.Update(ctdeal);
        }
        public static void Delete(String iD)
        {
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            ctdealDAL.Delete(iD);
        }
        public static tbCTDealCollection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            return ctdealDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            return ctdealDAL.Get(cri.Criter, 0, 0, tbCTDealColumns.madeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbCTDeal GetByID(String iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbCTDealColumns.madeal.ToString(), Condition.EQUAL, iD);
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            tbCTDealCollection ctdealCollection = ctdealDAL.Get(cri.Criter, 0, 0, tbCTDealColumns.madeal.ToString(), OrderDirection.ASC.ToString(), out total);
            if (ctdealCollection.Count > 0)
                return ctdealCollection[0];
            return null;
        }
        public static tbCTDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            return ctdealDAL.Get(cri.Criter, 1, number, tbCTDealColumns.madeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCTDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbCTDealDAL ctdealDAL = new tbCTDealDAL();
            return ctdealDAL.Get(cri.Criter, 1, number, tbCTDealColumns.madeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
